@extends('layouts.default') @section('main')
<link rel="stylesheet" href="/css/uniform.css" />
<link rel="stylesheet" href="/css/select2.css" />
<script src="{{URL::asset('js/My97DatePicker/')}}/WdatePicker.js"></script>
<div id="content">
	<div id="content-header">
		<div id="breadcrumb">
			<a href="{{url('home')}}" title="返回首页" class="tip-bottom"><i
				class="icon-home"></i> 首页</a> <a href="#" class="current">活动管理</a>
		</div>
	</div>
	<div class="container-fluid">
		<div class="row-fluid">
			<div class="span14">
				@if(in_array('add',$actions)) <a href="{{url('activity/create')}}"><button
						class="btn">新增</button></a> @endif
                    <form action="{{url('activity/search')}}" method="post">
                        <table>
                            <tr>
                                <th>
                                    <label >活动标题 :</label>
                                </th>
                                <th>
                                    <div class="controls">
                                        <input type="text" class="span11" name="subject" value="" placeholder="活动标题" />
                                    </div>
                                </th>
                                <th>
                                    <label >活动类型 :</label>
                                </th>
                                <th>
                                    <div class="controls">
                                        <select  name="type" class="span11" >
                                            <option value="">请选择</option>
                                            @foreach($type as $k=>$v)
                                            <option value="{{$k}}">{{$v['name']}}</option>
                                                @endforeach
                                        </select>
                                    </div>
                                </th>
                                <th>
                                    <label >活动开始时间 :</label>
                                </th>
                                <th>
                                    <div class="controls">
                                        <input type="text" class="span11" name="begin_time"
                                               placeholder="活动开始时间" onfocus="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})" />
                                    </div>
                                </th>
                                <th>
                                    <label >活动结束时间 :</label>
                                </th>
                                <th>
                                    <div class="controls">
                                        <input type="text" class="span11" name="end_time"
                                               placeholder="活动结束时间" onfocus="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})" />
                                    </div>
                                </th>
                                <th>
                                    <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                    <div class="controls">
                                        <button type="submit" class="btn btn-info">查询</button>
                                    </div>
                                </th>
                            </tr>
                        </table>
                    </form>
				<div class="widget-box">
					<div class="widget-title">
						<span class="icon"><i class="icon-th"></i></span>
						<h5>活动管理</h5>
					</div>
					<div class="widget-content nopadding">
						<table class="table table-bordered table-striped">
							<thead>
								<tr>
									<th>活动名称</th>
									<th>活动类型</th>
									<th>活动开始</th>
									{{--<th>活动结束</th>--}}
									<th>活动项目</th>
									<th>创客空间</th>
									<th>活动详情</th>
									<th>流程图</th>
									<th>签到管理</th>
									<th>二维码</th>
									<th>报名统计</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
								@foreach($activities as $key => $activity)
								<tr class="gradeX">
									<td title="{{$activity->subject}}">{{cut_str($activity->subject,10)}}</td>
									<td>@if(isset($type[$activity->type])){{$type[$activity->type]['name']}}@endif</td>
									<td>{{date('Y-m-d H:i:s',$activity->begin_time)}}</td>
									{{--<td>{{date('Y-m-d H:i:s',$activity->end_time)}}</td>--}}
									<td><a href="{{action('ActivityController@getActivityprojects',['aid'=>$activity->id])}}">点击管理</a></td>
									<td><a href="{{action('ActivityController@getActivityMaker',['aid'=>$activity->id])}}">点击管理</a></td>
									<td><a href="{{action('ActivityController@getActivitydetail',['aid'=>$activity->id])}}">点击查看</a></td>
                                    <td><a href="{{url('activityphoto/index?id='.$activity->id)}}">点击管理</a></td>
                                    <td><a href="{{url('activitysign/index?id='.$activity->id)}}">点击管理</a></td>
                                    <td><a href="{{url('activity/sign-code?id='.$activity->id)}}">点击查看</a></td>
                                    <td><a href="{{url('activity/statistic?id='.$activity->id)}}">点击查看</a></td>
                                    <td class="center">
                                        @if(in_array('edit',$actions)) <a data-original-title="编辑" class="tip" href="{{action('ActivityController@getEdit',['aid'=>$activity->id])}}"><i class="icon-pencil"></i></a> @endif
                                        @if(in_array('export',$actions)) <a data-original-title="导出" class="tip" href="{{url('activity/export?id='.$activity->id)}}"><i class="icon-external-link"></i></a> @endif
										@if(in_array('delete',$actions)) <a data-original-title="删除" data-toggle="modal" class="tip activity_delete" activity_id="{{$activity->id}}" href="#myAlert"> <i class="icon-remove"></i></a> @endif
									</td>
								</tr>
								@endforeach
							</tbody>
						</table>
					</div>
				</div>
                    <?php echo $activities->render();?>
      </div>
		</div>
	</div>
</div>
<div>
	<div id="myAlert" class="modal hide">
		<div class="modal-header">
			<button data-dismiss="modal" class="close" type="button">×</button>
			<h3>提示</h3>
		</div>
		<div class="modal-body">
			<p>确认删除这条数据吗？</p>
		</div>
		<div class="modal-footer">
			<a data-dismiss="modal" class="btn btn-primary" href="javascript:void(0);">确定</a>
			<a data-dismiss="modal" class="btn" href="javascript:void(0);">取消</a>
		</div>
	</div>
	<form action="{{url('activity/delete')}}" method="post"
		id="activityForm">
		<input type="hidden" name="aid" value="0">
	</form>
</div>
<script src="/js/jquery.min.js"></script>
<script src="/js/matrix.tables.js"></script>
<script src="/js/common.js"></script>
<script>
$(".activity_delete").click(function(){
	var activity_id = $(this).attr("activity_id");
	$("input[name='aid']").val(activity_id);
});
$(".btn-primary").click(function(){
	var activity_id = $("input[name='aid']").val();
	if(activity_id == 0){
		alert('参数异常');
		return;
	}
	ajaxRequest($('#activityForm').serializeArray(),$('#activityForm').attr('action'),function(data){
		if(data.status){
            alert(data.message);
            window.location.href = data.forwardUrl;
		}else{
			alert(data.message);
		}
	});
});
</script>
@stop
